
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region WarehouseAreaDAL
	public class WarehouseAreaDAL : DBContext
	{
		public List<WarehouseArea> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseAreasSelectAll");
            return GetEntityList<WarehouseArea>(cmd);
        }

        public WarehouseArea GetById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseAreaSelect");
            cmd.AddParameter("@Id", id);
            return GetSingleEntity<WarehouseArea>(cmd);
        }

		public List<WarehouseArea> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseAreaSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<WarehouseArea>(cmd);
        }

        public WarehouseArea Add(string paramCode, string paramName, string paramBarcode, Guid paramWarehouseId,
                                        string paramDescription, decimal paramSquareFeet, decimal paramSquareMeter, int paramShelfCapacity,
                                        string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseAreaInsert");
            cmd.AddParameter("@Code", paramCode);
            cmd.AddParameter("@Name", paramName);
            cmd.AddParameter("@Barcode", paramBarcode);
            cmd.AddParameter("@WarehouseId", paramWarehouseId);
            cmd.AddParameter("@Description", paramDescription);
            cmd.AddParameter("@SquareFeet", paramSquareFeet);
            cmd.AddParameter("@SquareMeter", paramSquareMeter);
            cmd.AddParameter("@ShelfCapacity", paramShelfCapacity);
            cmd.AddParameter("@CreatedBy", paramCreatedBy);
            return GetSingleEntity<WarehouseArea>(cmd);
        }

        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseAreaDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public WarehouseArea UpdateById(Guid paramId, string paramCode,	string paramName, string paramBarcode, 	Guid paramWarehouseId,
                                        string paramDescription, decimal paramSquareFeet, decimal paramSquareMeter, int paramShelfCapacity,
                                        string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseAreaUpdate");
			cmd.AddParameter("@Id", paramId);
			cmd.AddParameter("@Code", paramCode);
			cmd.AddParameter("@Name", paramName);
			cmd.AddParameter("@Barcode", paramBarcode);
			cmd.AddParameter("@WarehouseId", paramWarehouseId);
			cmd.AddParameter("@Description", paramDescription);
			cmd.AddParameter("@SquareFeet", paramSquareFeet);
			cmd.AddParameter("@SquareMeter", paramSquareMeter);
			cmd.AddParameter("@ShelfCapacity", paramShelfCapacity);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<WarehouseArea>(cmd);
        }
		
	}
	#endregion
}
